package com.gljx.web.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gljx.web.Entity.RepairShop;
import com.gljx.web.dao.CommonDao;
import com.gljx.web.dao.RepairShopMapper;
import com.gljx.web.service.RepairShopService;

@Service
@Transactional
public class RepairShopServiceImpl extends CommonDao implements RepairShopService{

	//自动注入
	@Autowired
	private RepairShopMapper repairShopMapper;
	
	/**
	 * 实现查询所有修理厂的方法
	 */
	@Override
	public List<RepairShop> queryRepairShopAll() {
		// TODO Auto-generated method stub
		return repairShopMapper.selectRepairShopAll();
	}

	@Override
	public List<RepairShop> queryRepairShopAllAsName(String name) {
		// TODO Auto-generated method stub
		return repairShopMapper.selectRepairShopAllByName(name);
	}

	/**
	 * 实现根据控制单元id查询
	 */
	@Override
	public List<RepairShop> queryRepairShopByFcontrolunitid(String companyId) {
		// TODO Auto-generated method stub
		return repairShopMapper.selectRepairShopByFcontrolunitid(companyId);
	}

	/**
	 * 实现根据控制单元id和简称查询
	 */
	@Override
	public List<RepairShop> queryRepairShopByFdescriptionL2(String companyId, String fsimplename) {
		// TODO Auto-generated method stub
		Map<String, String>map = new HashMap<>();
		map.put("companyId", companyId);
		map.put("fsimplename", fsimplename);
		return repairShopMapper.selectRepairShopByFdescriptionL2(map);
	}

	/**
	 * 实现查询上一个编码
	 */
	@Override
	public String selectFnumber(String companyId) {
		// TODO Auto-generated method stub
		return repairShopMapper.selectFnumber(companyId);
	}

	/**
	 * 实现添加
	 */
	@Override
	public void addRepairShop(RepairShop repairShop) {
		// TODO Auto-generated method stub
		repairShopMapper.insertSelective(repairShop);
	}

	/**
	 * 实现根据fid查询
	 */
	@Override
	public RepairShop queryRepairShopByFid(String fid) {
		// TODO Auto-generated method stub
		return repairShopMapper.selectByPrimaryKey(fid);
	}

	/**
	 * 实现修改
	 */
	@Override
	public void modifyRepairShop(RepairShop repairShop) {
		// TODO Auto-generated method stub
		repairShopMapper.updateByPrimaryKeySelective(repairShop);
	}

	/**
	 * 实现根据fid删除
	 */
	@Override
	public void deleteRepairShopByFid(String fid) {
		// TODO Auto-generated method stub
		repairShopMapper.deleteByPrimaryKey(fid);
	}

    @Override
    public List<RepairShop> queryRepairShop() {
        return repairShopMapper.selectRepairShop();
    }

}
